<template>
  <!--  页面跳转,表格数据也需要跳转-->
  <div style="padding:20px">
    <h3>编辑藏品类别信息</h3>
    <el-form :inline="true" :model="form" style="width:80%" label-width="100px">
      <el-form-item label="名称" prop="name">
        <el-input v-model="form.name" placeholder="请输入藏品名称"></el-input>
      </el-form-item>

      <el-form-item label="备注" prop="remark">
        <el-input v-model="form.remark" type="textarea" style="width:400px" placeholder="请输入备注内容"></el-input>
      </el-form-item>

      <el-form-item label="封面图" prop="cover">
        <el-input v-model="form.cover" placeholder="请输入图片链接"></el-input>
      </el-form-item>

      <el-form-item label="类别" prop="type">
        <el-input v-model="form.type" placeholder="请输入类别"></el-input>
      </el-form-item>
    </el-form>

    <div style="text-align:center;margin-top:30px">
      <el-button type="primary" @click="save" size="medium">提交</el-button>
      <!--      <el-button type="danger">返回列表</el-button>-->
    </div>
  </div>
</template>

<script>
import request from "@/utils/request";
export default {
  name: "EditCollectionsType",
  data(){
    return{
      form:{}
    }
  },
  created(){
    const id = this.$route.query.id
    //这个方法 将后台通过id查出来的collectionstype对象赋给form
    request.get("/collectionstype/"+ id).then(res => {
      //将后台查出的collectionstype对象赋值给form
      this.form = res.data
    })
  },
  methods: {
    save(){
      //  save方法用于提交数据
      request.put('/collectionstype/update',this.form).then(res => {
        if (res.code === '200'){
          this.$notify.success('更新成功')
          //  新增成功后清空输入框内数据
          this.$router.push("/collectionstypeList")
        } else{
          this.$notify.error(res.msg)
        }

      })
    }
  }
}
</script>

<style scoped>

</style>